/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package paquete;

import java.util.Iterator;
import java.util.List;
import org.hibernate.Session;

/**
 *
 * @author Home
 */
public class funcion {
    
    public funcion(){
    }
    
    
    public static List<SnaHorEspFisAca> consultar(){
    
        List<SnaHorEspFisAca> lista ;
        
        Session s = HibernateUtil.getSessionFactory().getCurrentSession();
        s.beginTransaction();
        lista = (List<SnaHorEspFisAca>)s.createQuery("from SnaHorEspFisAca").list();
      
        s.getTransaction().commit();
        
        return lista ;
    }
    
    public static List<Dia> consultarDias(){
    
        List<Dia> lista ;
        
        Session s = HibernateUtil.getSessionFactory().getCurrentSession();
        s.beginTransaction();
        lista = (List<Dia>)s.createQuery("from Dia").list();
      
        s.getTransaction().commit();
        
        return lista ;
    }
    
     public static void guardar(Object o){
       Session s = HibernateUtil.getSessionFactory().getCurrentSession();
       s.beginTransaction();
       s.save(o);
       s.getTransaction().commit();
   }
     
     
     public static boolean  consultarProfesor(String cedula){
    
        List<Profesor> lista ;
        
        Session s = HibernateUtil.getSessionFactory().getCurrentSession();
        s.beginTransaction();
        lista = (List<Profesor>)s.createQuery("from Profesor").list();
      
        s.getTransaction().commit();
        
        Iterator i = lista.iterator();
        
        while(i.hasNext()){
        
            Profesor p = (Profesor)i.next();
            if(p.getCedula().equalsIgnoreCase(cedula)){
                return true ;
            
            }
        }
        return false ;
    }
     
     public static boolean  consultarConserje(String cedula){
    
        List<Conserjes> lista ;
        
        Session s = HibernateUtil.getSessionFactory().getCurrentSession();
        s.beginTransaction();
        lista = (List<Conserjes>)s.createQuery("from Conserjes").list();
      
        s.getTransaction().commit();
        
        Iterator i = lista.iterator();
        
        while(i.hasNext()){
        
            Conserjes p = (Conserjes)i.next();
            if(p.getCedula().equalsIgnoreCase(cedula)){
                return true ;
            
            }
        }
        return false ;
    }
     
}
